package com.runshu.runshuwulian;

import androidx.multidex.MultiDexApplication;

import com.runshu.runshuwulian.bean.LoginBean;
import com.runshu.runshuwulian.utils.ToastUtils;
import com.runshu.runshuwulian.utils.UtilSharedPreference;

public class MApplication extends MultiDexApplication {
    public static MApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        ToastUtils.init(this);
    }

    public static MApplication getInstance() {
        return instance;
    }

    private LoginBean loginInfo;
    /**
     * 清空登录信息
     */
    public void removeUserInfo() {
        this.loginInfo = null;
        UtilSharedPreference.clearLoginInfo( this );
    }
    public LoginBean getLoginInfo() {
        if (loginInfo == null)
            loginInfo = UtilSharedPreference.getLoginInfo( this );
        return loginInfo;
    }

    public void setLoginInfo(LoginBean loginInfo) {
        this.loginInfo = loginInfo;
        UtilSharedPreference.saveLoginInfo( this, loginInfo );
    }
}
